package org.jtzc.springaiagent.agent.chain;

import org.jtzc.springaiagent.agent.BaseAgent;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author wu chuang
 * @description 拼写检查
 */
@Service
public class SpellingCheckerAgent implements BaseAgent {

    @Autowired
    private ChatClient chatClient;


    @Override
    public BaseAgent.AgentResponse execute(BaseAgent.AgentRequest request) {
        String system = "你做为一个拼写专家,帮我检查一下用户输入的拼写是否存在错误,如果有错误帮我修改一下,并且返回;如果没有错误就不要修改内容";
        String response = chatClient.prompt().system(system).user(request.prompt()).call().content();
        return new BaseAgent.AgentResponse(response, Map.of("SpellingCheckerAgent", "gpt-4"));
    }
}
